﻿/****************************************************************
*   作者：corer
*   创建时间：2018/3/2 11:12:40
*   描述说明：
*****************************************************************/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace ETSModel
{
  public class CountdownTimerComponent : MonoBehaviour
  {
    public static CountdownTimerComponent Instance;

    public int countDown = 0;

    private float timer = 0;

    public Action Callback;

    private void Awake()
    {
      Instance = this;
    }

    private void Update()
    {
      timer += Time.deltaTime;
      if (timer >= 1f)
      {
        timer = 0;
        countDown--;
        if (countDown == 0)
        {
          this.enabled = false;
          Callback?.Invoke();
        }
      }
    }
  }
}